package com.hexinfo.dmpro.data.transfer.common.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hexinfo.dmpro.data.transfer.common.dao.SourceRuleTableViewMapper;
import com.hexinfo.dmpro.data.transfer.common.model.SourceRuleTableView;
import com.hexinfo.dmpro.data.transfer.common.service.ISourceRuleTableViewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class SourceRuleTableViewService implements ISourceRuleTableViewService {

    @Autowired
    private SourceRuleTableViewMapper sourceRuleTableViewMapper;


    @Override
    public List<String> queryDatabaseList() {
        return sourceRuleTableViewMapper.queryDatabaseList();
    }

    @Override
    public List<String> querySourceList() {
        List<String>  sourceList = sourceRuleTableViewMapper.querySourceList();
        return sourceList.stream().filter(str -> StrUtil.isNotBlank(str)).collect(Collectors.toList());
    }

    @Override
    public List<String> queryTableNameListByDatabase(String databaseName) {
        return sourceRuleTableViewMapper.queryTableNameListByDatabase(databaseName);
    }

    @Override
    public List<SourceRuleTableView> queryTableListBySource(String sourceName) {
        return sourceRuleTableViewMapper.queryTableListBySource(sourceName);
    }

    @Override
    public List<SourceRuleTableView> queryTableListByDatabase(String databaseName) {
        return sourceRuleTableViewMapper.queryTableListByDatabase(databaseName);
    }

    @Override
    public List<SourceRuleTableView> queryByDbNameAndTableName(String databaseName, String tableName) {
        return sourceRuleTableViewMapper.queryByDbNameAndTableName(databaseName, tableName);
    }
}
